<template>
  <div>
    <table>
      <!-- 2. 使用tr组件, 传入需要的数据 -->
      <tr is="myTr" v-for="(item, i) in goodsArr" :key="i" :obj="item"></tr>
    </table>
    <p>All Number:{{ total }}</p>
  </div>
</template>

<script>
import MyTr from "./components/practise/MyTr.vue";
export default {
  data() {
    return {
      goodsArr: [
        {
          count: 0,
          goodsName: "Watermelon",
        },
        {
          count: 0,
          goodsName: "Banana",
        },
        {
          count: 0,
          goodsName: "Orange",
        },
        {
          count: 0,
          goodsName: "Pineapple",
        },
        {
          count: 0,
          goodsName: "Strawberry",
        },
      ],
    };
  },
  components: {
    MyTr,
  },
  computed: {
    total() {
      return this.goodsArr.reduce((prev, item) => prev + item.count * 1, 0);
    },
  },
};
</script>

<style>
</style>